﻿using Prism.Dialogs;
using Prism.Mvvm;
using Prism.Commands;
using System;

namespace YY.Admin.ViewModels.Dialogs
{
    public class WarningDialogViewModel : BindableBase, IDialogAware
    {
        public string Title => "警告";

        private string _message;
        public string Message
        {
            get => _message;
            set => SetProperty(ref _message, value);
        }

        // Prism.Dialogs 版本的 RequestClose 是属性
        public DialogCloseListener RequestClose { get; private set; }

        public DelegateCommand CloseCommand { get; }

        public WarningDialogViewModel()
        {
            CloseCommand = new DelegateCommand(CloseDialog);
        }

        private void CloseDialog()
        {
            RequestClose.Invoke(new DialogResult(ButtonResult.OK));
        }

        public bool CanCloseDialog() => true;

        public void OnDialogOpened(IDialogParameters parameters)
        {
            Message = parameters.GetValue<string>("message");
        }

        public void OnDialogClosed()
        {
        }
    }
}
